import unittest
from selenium import webdriver
from time import sleep
from Page.login import login_Page
from Page.settlement import settlement
from selenium.webdriver.common.by import By
class MyTestCase(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.lp = login_Page(self.driver)
        self.lp.openurl('http://49.233.136.131:7009/roncoo-pay-web-boss/login')
        self.lp.login_success()
        self.jiesuan = settlement(self.driver)
        print('开始')

    def tearDown(self):
        sleep(5)
        self.driver.quit()
        print('结束')

    def test_01_shenhe(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        dy1_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[12]/ul/li/div/a')
        dy1 = self.jiesuan.find_element(dy1_loc).text
        self.assertNotEqual(" 结算记录管理", dy1)


    def test_02_shenhe(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.shen()
        sleep(3)
        self.jiesuan.bei()
        sleep(2)
        self.jiesuan.ti()
        sleep(3)
        dy2_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[12]/ul/li/div/a')
        dy2 = self.jiesuan.find_element(dy2_loc).text
        self.assertNotEqual(" 结算记录管理", dy2)

    def test_03_chakan(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.chakan()
        sleep(3)
        dy3_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[12]/ul/li/div/a')
        dy3 = self.jiesuan.find_element(dy3_loc).text
        self.assertNotEqual(" 结算记录管理", dy3)


    def test_04_shenhe(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.dakuan()
        sleep(3)
        dy4_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[11]/h2')
        dy4 = self.jiesuan.find_element(dy4_loc).text
        self.assertNotEqual("  结算", dy4)

    def test_05_jiesuan(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.faqijiesuan()
        sleep(3)
        dy5_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[11]/h2')
        dy5 = self.jiesuan.find_element(dy5_loc).text
        self.assertNotEqual(" 结算管理", dy5)


    def test_06_shaocanshu(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.faqijiesuan()
        sleep(3)
        self.jiesuan.bh()
        sleep(2)
        self.jiesuan.ti()
        sleep(3)
        dy6_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[11]/h2')
        dy6 = self.jiesuan.find_element(dy6_loc).text
        self.assertNotEqual(" 必填字段", dy6)


    def test_07_zhenque(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.faqijiesuan()
        sleep(3)
        self.jiesuan.ti()
        sleep(3)
        dy7_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[11]/h2')
        dy7 = self.jiesuan.find_element(dy7_loc).text
        self.assertNotEqual(" 提交成功", dy7)


    def test_08_sanjiao(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.faqijiesuan()
        sleep(3)
        self.jiesuan.daosanjiao()
        sleep(3)
        dy8_loc = (By.XPATH, '//*[@id="navTab"]/ul/li[1]/a')
        dy8 = self.jiesuan.find_element(dy8_loc).text
        self.assertTrue("主页", dy8)

    def test_09_zhuye(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.faqijiesuan()
        sleep(3)
        self.jiesuan.daosanjiao()
        sleep(3)
        self.jiesuan.zhu()
        dy9_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[1]/div/p[1]/span')
        dy9 = self.jiesuan.find_element(dy9_loc).text
        self.assertTrue("龙果支付后台", dy9)


    def test_10_zhuye(self):
        self.jiesuan.jiesuan()
        sleep(2)
        self.jiesuan.jilu()
        sleep(2)
        self.jiesuan.faqijiesuan()
        sleep(3)
        self.jiesuan.daosanjiao()
        sleep(3)
        self.jiesuan.fanhuijiesuan()
        dy10_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[12]/ul/li/div/a')
        dy10 = self.jiesuan.find_element(dy10_loc).text
        self.assertNotEqual(" 记录", dy10)

if __name__ == '__main__':
    unittest.main()
